home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************************
- * Group Transfer program
- *
- * (C) 1994 Rob Harford
- * Last Modified : 15 june 1994
- * 9/feb/94 - fixed problem with group names compising of other group names
- * 14/jun/1994 - fixed problem with spaces at the end of group names
- * 15/june/1994 - Added the 3d Dialog boxes
- * Release version 1.04
- ****************************************************************************************/
-
- /***************************************************************************************
- *
- * Delare sub routines to enable 3d Dialog boxes within script maker
- *
- ******************************************************************************************/
-
-
- declare function Ctl3dRegister lib "ctl3d.dll" (byval hInst as Long) as Integer
- declare function Ctl3dAutoSubClass lib "ctl3d.dll" (byval hInst as Long) as Integer
- declare function Ctl3dUnRegister lib "ctl3d.dll" (byval hInst as Long) as Integer
-
-
- /***************************************************************************************
- *
- * Function: Encap$
- * Parameters:Cmd$
- * Purpose: This routine encapusulates the groupname, to protect against spaces at
- * the end or start of a group name
- *
- ******************************************************************************************/
-
- function Encap$(groupname$)
- Encap$=chr$(34)+groupname$+chr$(34)
- end function
-
- /***************************************************************************************
- *
- * Function: DDEexe
- * Parameters:Cmd$
- * Purpose: This sub routine opens a DDE channel to the current shell, and then
- * sends the command string ,held in Cmd$
- *
- ******************************************************************************************/
-
- sub DDEexe(Cmd$)
-
- Dim DDEchannel as Integer
-
- DDEchannel = DDEInitiate("progman", "progman")
- if DDEchannel = FALSE then
- MsgBox "Unable To Access Windows Shell. Either the primary Windows shell is not responding, or is incompatible with this script..", 16, "FATAL ERROR"
- Else
- DDEExecute DDEchannel, Cmd$
- DDETerminate DDEchannel
- End If
- end sub
-
- /* **************************************************************************************
- *
- * Function: DDEget$
- * Parameters:Cmd$
- * Purpose: This function opens a DDE channel to the current shell, then requests
- * information based upon the contents of Cmd$
- *
- ******************************************************************************************/
- function DDEget$(g$)
-
- Dim DDEchannel as Integer
-
- DDEchannel = DDEInitiate("progman", "progman")
- if DDEchannel = FALSE then
- MsgBox "Unable To Access Windows Shell. Either the primary Windows shell is not responding, or is incompatible with this script.", 16, "FATAL ERROR"
- Else
- DDEget$=DDErequest$(DDEchannel,g$)
- DDETerminate DDEchannel
- end if
- end function
-
-
- /* **************************************************************************************
- *
- * Function: DeleteItem
- * Parameters:Group$
- * Purpose: This deletes an item from within a group from the shell
- * e.g DeleteItem "File Manager"
- ******************************************************************************************/
-
- sub DeleteItem (Group$)
- Group$= "[ReplaceItem("+Group$+")]"
- DDEExe Group$
- End Sub
-
- /* **************************************************************************************
- *
- * Function: CreateGroup
- * Parameters:Group$
- * Purpose: This creates a group from the shell
- * e.g CreateGroup "Main"
- ******************************************************************************************/
-
- sub CreateGroup (Group$)
- Group$= "[CreateGroup("+CHR$(34)+Group$+CHR$(34)+", )]"
- DDEExe Group$
- End Sub
- /* **************************************************************************************
- *
- * Function: MakeCompat$
- * Parameters:Data$
- * Purpose: This untily removes brackets which may offend program manager.
- *
- ******************************************************************************************/
-
-
- function MakeCompat$(Data$)
-
- a=0
-
- Bad$="[]{}"
- New$=""
-
- while (a<len(Data$))
- a=a+1
- c$=Mid$(Data$,a,1)
- if (InStr(Bad$,c$)<>0) then
- New$=New$+"."
- else
- New$=New$+c$
- End if
- Wend
- MakeCompat$=New$
- end function
-
- /* **************************************************************************************
- *
- * Function: MakeComma$
- * Parameters:Information$
- * Purpose: This converts the information received by GetGroups, and then adds
- * commas between each group name.
- *
- ******************************************************************************************/
-
-
- Function MakeComma$(Information$)
-
- a=1
- mk$ =""
- while (a<=Len(Information$))
- if Mid$(Information$,a,1)=Chr$(13) then
- Mk$=Mk$ + ","
- a=a+1
- else
- Mk$=Mk$ + Mid$(Information$,a,1)
- End If
-
- a=a+1
- Wend
- MakeComma$=mk$
-
- End Function
-
- /* **************************************************************************************
- *
- * Function: DeleteGroup
- * Parameters:Group$
- * Purpose: This Deletes a group from the shell
- * e.g DeleteGroup "Main"
- ******************************************************************************************/
-
-
- sub DeleteGroup (Group$)
- GroupList$=MakeComma$(DDEget$("PROGMAN"))
- GroupList$=","+GroupList$+","
- If InStr(GroupList$,","+Group$+",")<>0 then
- Group$= "[DeleteGroup("+CHR$(34)+Group$+CHR$(34)+")]"
- DDEExe Group$
- end if
- End Sub
-
- /* **************************************************************************************
- *
- * Function: AddItem
- * Parameters:Group$
- * Purpose: This adds a new item to the currently highlighted group
- * AddItem "item data"
- * e.g.
- * AddItem Item$
- * Items$ =Command Line including parameters+
- * Title of icon+
- * Icon Path+
- * Icon Index (default is zero for the first index)+
- * Xpos (position of icon on X axis)+
- * Ypos (position of icon on Y axis)+
- * Startup directory
- *
- * Notes:The items "Command Line","Title os Icon" need to be enclosed within quotes
- * Each item needs to seperated by a comma
- ******************************************************************************************/
-
- sub AddItem (Group$)
- Group$= "[AddItem("+Group$+")]"
- DDEExe Group$
- End Sub
-
- /* **************************************************************************************
- *
- * Function: ShowGroup
- * Parameters:Group$
- * Purpose: This brings a group to the front and highlights it
- * e.g ShowGroup "Main"
- ******************************************************************************************/
-
- sub ShowGroup(Group$)
-
- Group$="[ShowGroup("+Group$+")]"
- DDEexe Group$
-
- End Sub
-
-
- /* **************************************************************************************
- *
- * Function: GetGroup$
- * Parameters:NONE
- * Purpose: This returns a list of groups under your current shell
- *
- ******************************************************************************************/
-
- Function GetGroup$()
-
- GetGroup$=DDEget("PROGMAN")
-
- End Function
-
-
-
-
- /* **************************************************************************************
- *
- * Function: MakeNDWValid$
- * Parameters:Cmd$
- * Purpose: This converts the information received from the shell into a format
- * acceptable to be sent back to the shell
- *
- ******************************************************************************************/
-
- function MakeNDWValid$(Cmd$)
-
- Dim Comma1,Comma2,Comma3,Comma4 as integer
- Dim Comma5,Comma6,Comma7,Comma8 as integer
- Dim FileName$,Description$,IconFile$,StartDir$ as String
- dim IconPos as Long
-
- Comma1 = InStr(1,Cmd$,",")
- Comma2 = InStr(Comma1+1,Cmd$,",")
- Comma3 = InStr(Comma2+1,Cmd$,",")
- Comma4 = InStr(Comma3+1,Cmd$,",")
- Comma5 = InStr(Comma4+1,Cmd$,",")
- Comma6 = InStr(Comma5+1,Cmd$,",")
- Comma7 = InStr(Comma6+1,Cmd$,",")
- Comma8 = InStr(Comma7+1,Cmd$,",")
-
- Description$ = MakeCompat$(Mid$(Cmd$,1,Comma1-1))
- FileName$ = MakeCompat$(Mid$(Cmd$,Comma1+1,Comma2-Comma1-1))
- StartDir$ = Mid$(Cmd$,Comma2+1,Comma3-Comma2-1)
- IconFile$ = Mid$(Cmd$,Comma3+1,Comma4-Comma3-1)
- x$ = Mid$(Cmd$,Comma4+1,Comma5-Comma4-1)
- Y$ = Mid$(Cmd$,Comma5+1,Comma6-Comma5-1)
- z$ = Mid$(Cmd$,Comma6+1,Comma7-Comma6-1)
- H$ = Mid$(Cmd$,Comma7+1,Comma8-Comma7-1)
- IconPos=val(z$)
-
- If (IconPos < 0) then
- ' Ndw is the shell, so we must add the magic number
- IconPos=IconPos+32768
- end if
-
- Cmd$=FileName$ +","+ Description$ +","+IconFile$+","+str$(IconPos)+","+x$+","+y$+","+StartDir$+","+h$
- MakeNDWValid$=Cmd$
- end function
-
-
- /* **************************************************************************************
- *
- * Procedure: InformUser
- * Parameters:Cmd% , Comp$
- * Purpose: This allows the program to inform the user of what is happening
- * Notes: Legal command values:
- * 1= Open Window
- * 2= Update Message
- * 3= Close Windows
- * Legel Comp values are 0-100
- ******************************************************************************************/
-
- sub InformUser(Cmd%,Comp%)
-
- if Cmd%=1 then 'Create Window
- MsgOpen "Saving Group Information..Please Wait..",0,0,1,1900,2550
- end If
-
- If Cmd%=2 then ' Update Thermometer
- MsgSetThermometer Comp%
- End if
-
- If Cmd%=3 then 'Close down Completed
- MsgClose
- MsgBox "Finishing saving group information",0,"Save 'A Group"
- End if
-
-
- end sub
-
-
- /* **************************************************************************************
- *
- * Function: SaveGroupNames
- * Parameters:Grp$
- * Purpose: This converts the information received by GetGroups, into a list of groups
- * in the file GROUPS.INI
- * Notes: The program will exclude any groups with the same name as your "Quick Access"
- * Groups
- *
- *
- ******************************************************************************************/
-
- sub SaveGroupNames(Grp$)
-
- a=0
- b=1
- c=1
- QAGrp$=Ucase$(ReadIni$("Quick Access","MainGroup","NDW.INI"))
- While (c<=len(Grp$))
-
- b=InStr(c,Grp$,",")
- g$=Mid$(Grp$,c,b-c)
- if (Ucase$(g$)<>QAGrp$) then
- a=a+1
- l$="GROUP"+Str$(a)
- WriteIni "GROUPS",l$,encap$(g$),"GROUPS.INI"
-
- end if
- c=b+1
- Wend
- WriteIni "GROUPS","TOTAL",Str$(a),"GROUPS.INI"
- WriteIni "GROUPS","DATE",Date$(),"GROUPS.INI"
- end sub
-
-
-
- /* **************************************************************************************
- *
- * Function: SaveGroupData
- * Parameters:Group$
- * Purpose: This saves the information for a specific group to the Groups.INI file
- *
- ******************************************************************************************/
-
-
- sub SaveGroupData(Group$)
-
- GroupInfo$=DDEget$(Group$)
-
- a=1
- b=1
- c=1
- GroupInfo$ = Mid$(GroupInfo$,InStr(c,GroupInfo$,chr$(13))+1,len(GroupInfo$))
- While (c<>len(GroupInfo$))
- b=InStr(c,GroupInfo$,chr$(13))
- g$=Mid$(GroupInfo$,c+1,b-c)
- G$ = MakeNDWValid$(G$)
- l$="Item"+Str$(a)
- WriteIni Group$,l$,g$,"GROUPS.INI"
- a=a+1
- c=b+1
- Wend
- WriteIni Group$,"TOTAL",str$(a-1),"GROUPS.INI"
-
- End Sub
-
-
- /* **************************************************************************************
- *
- * Function: SaveGroupData
- * Parameters:Group$
- * Purpose: This saves the information for a specific group to the Groups.INI file
- *
- ******************************************************************************************/
-
- sub SaveAllGroups(Group$)
-
-
- c=0
- TotalGroups = Val ( ReadIni$("Groups","TOTAL","GROUPS.INI"))
- InformUser 1,0
- While (c<TotalGroups)
- c=c+1
- l$=Str$(c)
- l$="GROUP"+l$
- g$=ReadIni$("GROUPS",l$,"GROUPS.INI")
- InformUser 2,int((c/TotalGroups)*100)
- SaveGroupData(g$)
- Wend
- InformUser 3,0
- end sub
-
- /* **************************************************************************************
- *
- * Function: RestoreGroup
- * Parameters:Group$
- * Purpose: This rebuilds the group based upon information for a specific group
- * in the Groups.INI file
- *
- ******************************************************************************************/
-
- sub RestoreGroup(Group$)
-
-
- Dim TotalItems as Integer
- Dim CurrentItem as Integer
- Dim L$ as String
-
- TotalItems=0
- CurrentItem=0
-
- TotalItems = Val( ReadIni$(Group$,"TOTAL","GROUPS.INI") )
-
- If TotalItems >50 then
- TotalItems = 50
- End if
-
- If (TotalItems <> 0) then
- Grp$ = Group$
- CreateGroup (Grp$)
- CurrentItem=1
-
- While (CurrentItem <= TotalItems)
-
- l$="Item"+Str$(CurrentItem)
- Cmd$=ReadIni$(Group$,l$,"GROUPS.INI")
- Comma1 = InStr(Cmd$,",")
- Title$=Mid$(Cmd$,Comma1+1,InStr(Comma1+1,Cmd$,",")-Comma1-1)
- AddItem Cmd$
- CurrentItem=CurrentItem+1
- Wend
- End if
- end sub
-
- /* **************************************************************************************
- *
- * Function: CheckRestore
- * Parameters:None
- * Purpose: This confirm's whether the user is sure about the restore.
- *
- ******************************************************************************************/
-
-
- function CheckRestore(Msg$)
-
- GroupDate$ = ReadIni$("GROUPS","DATE","GROUPS.INI")
-
- Begin Dialog ConfirmDialog 125,26,214,158, "Confirm Restoration of Groups"
- PushButton 30,120,60,20, "Continue"
- CancelButton 129,120,60,20
- Text 59,8,114,8, "Restoration of Groups"
- Text 98,60,43,8, GroupDATE$
- Text 10,30,96,8, "You are about to restore your"
- Text 10,60,88,8, "groups was taken on the :"
- Text 10,45,193,8, "from the GROUPS.INI file. The last Snapshot of your"
- Text 107,30,100,8, Msg$
- Text 11,82,174,8, "If you wish to proceed, then Click 'Continue'"
- Text 11,95,174,8, "Otherwise, click on 'Cancel' to exit"
- End Dialog
-
- Dim TmpDlg as ConfirmDialog
-
- CheckRestore=Dialog(TmpDlg)
-
- end function
-
-
- /* **************************************************************************************
- *
- * Function: RestoreAllGroup
- * Parameters:None
- * Purpose: This rebuilds all the groups based upon information in the Groups.INI file
- *
- ******************************************************************************************/
-
- sub RestoreAllGroups()
-
- Dim TotalGroups,CurrentGroup as Integer
- Dim l$,Group$ as String
-
- TotalGroups=0
- CurrentGroup=0
-
- TotalGroups = val( ReadIni$("GROUPS","TOTAL","GROUPS.INI"))
-
- if TotalGroups <> 0 then
-
- if CheckRestore("program groups")<>0 then
-
- CurrentGroup=1
- While (CurrentGroup<=TotalGroups)
-
- l$="GROUP"+Str$(CurrentGroup)
- Group$ = ReadIni$("GROUPS",l$,"GROUPS.INI")
- Grp$ = Group$
- DeleteGroup Grp$
- Grp$ = Group$
- CreateGroup Grp$
- RestoreGroup Group$
- CurrentGroup=CurrentGroup+1
- Wend
- MsgBox "Finishing restoring group information",0,"Save 'A Group"
- End If
- End if
-
- End Sub
-
-
- /* **************************************************************************************
- *
- * Function: RestoreOneGroup
- * Parameters:None
- * Purpose: This rebuilds one the groups based upon information in the Groups.INI file
- *
- ******************************************************************************************/
-
- sub RestoreOneGroup()
-
- Dim GrpList$ (1 to 60)
-
- Begin Dialog RestDlg 176,32,135,157, "Restore One Group"
- CancelButton 81,140,41,14
- PushButton 10,140,52,14, "Restore"
- ListBox 14,15,110,96, GrpList$, .GrpSelected
- Text 3,120,128,15, "Select Group to restore then click on 'Restore' or 'Cancel' to exit."
- End Dialog
-
-
- Dim SelDlg as RestDlg
-
- TotalGroups=0
-
- TotalGroups = val( ReadIni$("GROUPS","TOTAL","GROUPS.INI"))
-
- if (TotalGroups <> 0) then
- ReDim GrpList$ (1 to TotalGroups+1)
- Counter = 0
- While (Counter <=TotalGroups)
- Counter=Counter+1
- Itm$ = "GROUP"+Str$(Counter)
- GrpList$ (Counter) = ReadIni$("GROUPS",Itm$,"GROUPS.INI")
- Wend
- result=Dialog(SelDlg)
- if (result<>0) then
- Group$=GrpList$(SelDlg.GrpSelected)
- if (CheckRestore("the group "+group$+" from the")<>0) then
- RestoreGroup(Group$)
- MsgBox "Finishing restoring group information",0,"Save 'A Group"
- End if
- End if
-
- End if
- end sub
-
- /* **************************************************************************************
- *
- * Function: main
- * Parameters:None
- * Purpose: This is the main calling routine, execution starts here.
- *
- ******************************************************************************************/
-
-
- const IDB_CANCEL = 0
- const IDB_SAVE = 1
- const IDB_RESTORE_ONE = 2
- const IDB_RESTORE_ALL = 3
-
- sub main()
-
- ' Enable 3D Dialog box effects
-
- result=Ctl3dRegister(0)
- if (result = 1) then
- result=Ctl3dAutoSubClass(0)
- Enable3D=1
- end if
-
- On Error goto ErrorMsg
-
- Begin Dialog MenuDialog 53,45,358,137, "Save 'A Group"
- CancelButton 280,100,70,20
- PushButton 280,15,70,20, "Save All Groups"
- PushButton 280,65,70,20, "Restore One Group"
- PushButton 280,40,70,20, "Restore All Groups"
- Text 99,31,57,8, "By Rob Harford"
- Text 49,19,214,8, "Writen using the Symantec Scripting Language"
- Text 100,8,75,8, "DDE Example program"
- Text 20,100,254,8, "'Restore All Groups' will restore the backup made by using 'Save ALL Groups'"
- Text 20,90,236,8, "'Save All Groups' will make a copy the groups under your current shell."
- Text 22,50,196,8, "This utility will save and restore groups from different shells"
- Text 22,65,238,8, "This program will run under different shells (e.g NDW,Program Manager)"
- Text 85,78,81,8, "------------------------------------"
- Text 20,110,256,8, "'Restore One Group' will allow you to restore just one group from your backup"
- Text 20,120,256,8, "'Cancel' will exit from this program"
- Text 341,127,14,8, "1.4"
- End Dialog
-
- Dim Dialog1 as MenuDialog
-
- result =-1
- While (Result<>0)
- result = Dialog(Dialog1)
- if result = IDB_SAVE then
- Group$ = GetGroup$()
- Group$ = MakeComma$(Group$)
- SaveGroupNames(Group$)
- SaveAllGroups(Group$)
- end if
-
- if result = IDB_RESTORE_ALL then
- RestoreAllGroups
- end if
-
- if result = IDB_RESTORE_ONE then
- RestoreOneGroup
- end if
- Wend
- Goto GoodEnd
-
- ErrorMsg:
- MsgBox "Sorry a Fatal Error occured"
-
- GoodEnd:
-
- ' Remove 3d Dialogs
- if (Enable3D=1) then
- result=Ctl3dUnRegister(0)
- Sleep 500
- end if
-
- end sub
-
-